<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/7/16 0016
  Time: 上午 10:54
   专区商品
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
    <head>
        <title>Title</title>
        <script src="../../js/jquery-3.3.1.min.js" charset="utf-8"></script>
        <script src="../../js/cookie/jquery.cookie.js" charset="utf-8"></script>
        <link rel="stylesheet" href="../../layui-v2.4.5/layui/css/layui.css" media="all">
        <script src="../../layui-v2.4.5/layui/layui.js" charset="utf-8"></script>
    </head>
</head>
<body>
<style>
    .layui-form{
        margin-bottom: 120px;
    }
</style>
<br><br><br>
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right;margin-right: 100px"  href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:30px">ဂ</i></a>

<div class="layui-form">
    <form class="layui-form" action="">
        <table class="layui-table">
            <thead>
            <tr>
                <th>提现人</th>
                <th>金额</th>
                <th>提现方式</th>
                <th>提现账户</th>
                <th>电话</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${pageUtil.list}" var="rl">
                <tr>
                    <td>${rl.realName}</td>
                    <td>${rl.money}</td>
                    <td>${rl.strType}</td>
                    <td>${rl.accountNumber}</td>
                    <td>${rl.tel}</td>
                    <td>${rl.strState}</td>
                    <td>
                        <button type="button" class="layui-btn" onclick="savewithdrawLogsState('${rl.id}','${rl.memberId}','${rl.money}',1);">确认已打款</button>
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <button type="button" class="layui-btn layui-btn-danger" onclick="savewithdrawLogsState('${rl.id}',4);">删除</button>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </form>



    <div id="page"></div>
    <script>

        layui.use('laypage', function(){
            var laypage = layui.laypage;
            //完整功能
            laypage.render({
                elem: 'page'
                ,count: ${pageUtil.totalRows}
                ,curr:${page}
                ,hash:true
                ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
                ,jump: function(obj, first){
                    console.log(obj);
                    //首次不执行
                    if(!first){
                        console.log("123456");
                        //do something
                        window.location.href="/shop/withdrawLogs?page="+obj.curr+"&limit="+obj.limit;
                    }

                }
            });

        });


    </script>

</div>
<script>
    var layer;
    layui.use('layer', function(){
        layer = layui.layer;
    });


    /*改变状态*/
    function savewithdrawLogsState(id,memberId,money,state) {
        if (state==4){//删除
            console.log("执行删除")
            layer.confirm('确定要删除？', {
                btn: ['确定', '取消',] //可以无限个按钮
                ,btn1: function(index, layero){
                    console.log("删除提现记录");

                    $.ajax({
                        url:'/shop/savewithdrawLogsState',
                        type:'POST', //GET
                        async:true,    //或false,是否异步
                        data:{
                            id:id,
                            state:state,
                            money:money,
                            memberId:memberId
                        },
                        timeout:5000,    //超时时间
                        dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                        beforeSend:function(xhr){
                            /*console.log(xhr)
                             console.log('发送前')*/
                        },
                        success:function(dataA){
                            console.log(dataA);
                            if (dataA.code=='000000'){
                                window.location.reload();
                                // 获得frame索引
                            }else {
                                layer.msg("体现失败",{time:1000,icon: 5});
                            }
                        },
                        error:function(xhr,textStatus){
                            console.log('错误')
                            console.log(xhr)
                            console.log(textStatus)
                        },
                        complete:function(){
                            //console.log('结束')
                        }
                    })

                },btn2: function(index, layero){
                    console.log("不删除");
                }
            });
            return false;
        }


        $.ajax({
            url:'/shop/savewithdrawLogsState',
            type:'POST', //GET
            async:true,    //或false,是否异步
            data:{
                id:id,
                state:state,
                money:money,
                memberId:memberId
            },
            timeout:5000,    //超时时间
            dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
            beforeSend:function(xhr){
                /*console.log(xhr)
                 console.log('发送前')*/
            },
            success:function(dataA){
                console.log(dataA);
                if (dataA.code=='000000'){
                    window.location.reload();
                    // 获得frame索引
                }else {
                    layer.msg("删除失败",{time:1000,icon: 5});
                }
            },
            error:function(xhr,textStatus){
                console.log('错误')
                console.log(xhr)
                console.log(textStatus)
            },
            complete:function(){
                //console.log('结束')
            }
        })
    }


</script>
</body>
</html>
